﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Easy.Mvc.Controllers;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using ZKEACMS.Demo.Models;
using ZKEACMS.Demo.Service;

namespace ZKEACMS.Demo.Controllers
{
    public class HomeController : Controller// BasicController<Models.TestEntity, int, IDemoService>
    {
        public IDemoService _demoService;

        public HomeController(IDemoService service) //: base(service)
        {
            _demoService = service;
        }

        // GET: Home
        public IActionResult Index()
        {
            return View();
        }

        public IActionResult Test()
        {
            var modelList = _demoService.GetList(2, 10);

            var model = new TestEntity
            {
                //ID = 7687,
                Name = JsonConvert.SerializeObject(modelList)
            };

            //for (int i = 0; i < 100; i++)
            //{
            //    _demoService.Add(new TestEntity
            //    {
            //        //ID = 7687,
            //        Name = "xxx_" + DateTime.Now.ToShortDateString()
            //    });
            //}

            return View(model);
        }

        //// GET: Home/Details/5
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        //// GET: Home/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        //// POST: Home/Create
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create(IFormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add insert logic here

        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        //// GET: Home/Edit/5
        //public ActionResult Edit(int id)
        //{
        //    return View();
        //}

        //// POST: Home/Edit/5
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit(int id, IFormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add update logic here

        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        //// GET: Home/Delete/5
        //public ActionResult Delete(int id)
        //{
        //    return View();
        //}

        //// POST: Home/Delete/5
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Delete(int id, IFormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add delete logic here

        //        return RedirectToAction(nameof(Index));
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}
    }
}